import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

//Jory Folker

public class MessageHandler {
	static ServerSocket server;
    static Socket client;
    static BufferedReader is;
    static PrintWriter os;
    static boolean isServer;
	
    
    
    
    private static class keyL implements KeyListener{
        TextArea area;
        TextField input;
        public keyL(TextArea area, TextField input){
            this.area = area;
            this.input = input;
        }
        
        @Override
        public void keyTyped(KeyEvent e) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public void keyPressed(KeyEvent e) {
            if(e.getKeyCode() == 10){
                area.append((isServer ? "[Server]: " : "[Client]: ") + input.getText() + "\n");
                if(os != null){
                    os.println(input.getText());
                }else{
                    System.out.println("Output Stream not yet ready");
                }
                input.setText("");
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }
        
    }
}
